```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>链表重排算法可视化</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-section {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #2d3748;
            border-radius: 0.5rem;
            position: relative;
        }
        .code-block pre {
            margin: 0;
            padding: 1.5rem;
            overflow-x: auto;
        }
        .code-block .copy-btn {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            background: rgba(255,255,255,0.1);
            border: none;
            color: white;
            border-radius: 0.25rem;
            padding: 0.25rem 0.5rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        .code-block .copy-btn:hover {
            background: rgba(255,255,255,0.2);
        }
        .step-card {
            transition: all 0.3s ease;
            border-radius: 0.5rem;
            overflow: hidden;
        }
        .step-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }
        .list-node {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: #4299e1;
            color: white;
            font-weight: bold;
            margin: 0 10px;
            position: relative;
        }
        .list-node:after {
            content: "";
            position: absolute;
            right: -15px;
            width: 20px;
            height: 2px;
            background-color: #cbd5e0;
        }
        .list-node:last-child:after {
            display: none;
        }
        .list-node.odd {
            background-color: #4299e1;
        }
        .list-node.even {
            background-color: #9f7aea;
        }
        .list-node.sorted {
            background-color: #48bb78;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-section text-white py-20 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4">链表重排算法可视化</h1>
                    <p class="text-xl mb-8 opacity-90">将奇偶位分别排序的链表转换为完全升序链表</p>
                    <div class="flex space-x-4 mb-8">
                        <div class="flex items-center">
                            <div class="list-node odd">1</div>
                            <div class="list-node even">4</div>
                            <div class="list-node odd">3</div>
                            <div class="list-node even">2</div>
                            <div class="list-node odd">5</div>
                        </div>
                        <i class="fas fa-arrow-right text-2xl self-center"></i>
                        <div class="flex items-center">
                            <div class="list-node sorted">1</div>
                            <div class="list-node sorted">2</div>
                            <div class="list-node sorted">3</div>
                            <div class="list-node sorted">4</div>
                            <div class="list-node sorted">5</div>
                        </div>
                    </div>
                    <a href="#solution" class="bg-white text-indigo-600 hover:bg-gray-100 px-6 py-3 rounded-lg font-medium inline-block transition duration-300">
                        <i class="fas fa-arrow-down mr-2"></i>查看解决方案
                    </a>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="w-full max-w-md">
                        <div class="mermaid">
                            graph LR
                            A[原始链表] --> B[分离奇偶位]
                            B --> C[奇数位链表]
                            B --> D[偶数位链表]
                            C --> E[保持升序]
                            D --> F[反转降序]
                            E --> G[合并两个链表]
                            F --> G
                            G --> H[完全升序链表]
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Problem Section -->
    <section class="py-16 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="mb-12 text-center">
                <h2 class="text-3xl font-bold mb-4">问题分析</h2>
                <div class="w-20 h-1 bg-indigo-500 mx-auto"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div>
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-link text-indigo-500 mr-3"></i>链表结构
                    </h3>
                    <p class="text-gray-700 mb-4">假设链表中奇数位的元素（1st、3rd、5th等位置）是升序的。偶数位的元素（2nd、4th、6th等位置）是降序的。</p>
                    <div class="flex justify-center my-6">
                        <div class="flex items-center bg-gray-100 p-4 rounded-lg">
                            <div class="list-node odd">1</div>
                            <div class="list-node even">4</div>
                            <div class="list-node odd">3</div>
                            <div class="list-node even">2</div>
                            <div class="list-node odd">5</div>
                        </div>
                    </div>
                    <p class="text-gray-700">图示：蓝色节点为奇数位(升序)，紫色节点为偶数位(降序)</p>
                </div>
                <div>
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-bullseye text-indigo-500 mr-3"></i>目标
                    </h3>
                    <p class="text-gray-700 mb-6">将链表中的所有元素排序，使得整个链表成为一个升序链表。</p>
                    <div class="flex justify-center my-6">
                        <div class="flex items-center bg-gray-100 p-4 rounded-lg">
                            <div class="list-node sorted">1</div>
                            <div class="list-node sorted">2</div>
                            <div class="list-node sorted">3</div>
                            <div class="list-node sorted">4</div>
                            <div class="list-node sorted">5</div>
                        </div>
                    </div>
                    <p class="text-gray-700">图示：绿色节点表示完全排序后的链表</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Solution Section -->
    <section id="solution" class="py-16 px-4 bg-gray-100">
        <div class="container mx-auto max-w-6xl">
            <div class="mb-12 text-center">
                <h2 class="text-3xl font-bold mb-4">实现步骤</h2>
                <div class="w-20 h-1 bg-indigo-500 mx-auto"></div>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8 mb-12">
                <div class="step-card bg-white p-6 shadow-md">
                    <div class="text-indigo-500 text-4xl mb-4">
                        <i class="fas fa-code-branch"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">1. 分离奇偶位节点</h3>
                    <p class="text-gray-700 mb-4">遍历链表，将奇数位和偶数位的节点分别分到两个独立的链表中。</p>
                    <div class="code-block text-sm">
                        <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
                        <pre class="text-gray-300"><code>public static ListNode[] splitOddEven(ListNode head) {
    ListNode oddHead = new ListNode(0); // 虚拟头节点
    ListNode evenHead = new ListNode(0); // 虚拟头节点
    ListNode odd = oddHead;
    ListNode even = evenHead;
    ListNode current = head;
    boolean isOdd = true;

    while (current != null) {
        if (isOdd) {
            odd.next = current;
            odd = odd.next;
        } else {
            even.next = current;
            even = even.next;
        }
        current = current.next;
        isOdd = !isOdd;
    }

    odd.next = null; // 结束奇数链表
    even.next = null; // 结束偶数链表

    return new ListNode[]{oddHead.next, evenHead.next};
}</code></pre>
                    </div>
                </div>
                
                <div class="step-card bg-white p-6 shadow-md">
                    <div class="text-indigo-500 text-4xl mb-4">
                        <i class="fas fa-sort-amount-up"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">2. 排序处理</h3>
                    <p class="text-gray-700 mb-4">对奇数位链表保持原顺序，对偶数位链表进行反转后再排序。</p>
                    <div class="code-block text-sm">
                        <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
                        <pre class="text-gray-300"><code>// 反转链表
public static ListNode reverseList(ListNode head) {
    ListNode prev = null;
    ListNode curr = head;
    while (curr != null) {
        ListNode next = curr.next;
        curr.next = prev;
        prev = curr;
        curr = next;
    }
    return prev;
}

// 排序链表
public static ListNode sortList(ListNode head) {
    LinkedList&lt;Integer&gt; list = new LinkedList&lt;&gt;();
    ListNode current = head;
    while (current != null) {
        list.add(current.val);
        current = current.next;
    }
    Collections.sort(list);

    ListNode sortedHead = new ListNode(list.get(0));
    ListNode sortedCurrent = sortedHead;
    for (int i = 1; i &lt; list.size(); i++) {
        sortedCurrent.next = new ListNode(list.get(i));
        sortedCurrent = sortedCurrent.next;
    }
    return sortedHead;
}</code></pre>
                    </div>
                </div>
                
                <div class="step-card bg-white p-6 shadow-md">
                    <div class="text-indigo-500 text-4xl mb-4">
                        <i class="fas fa-merge"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">3. 合并链表</h3>
                    <p class="text-gray-700 mb-4">将排序后的奇数位链表和偶数位链表合并为一个升序链表。</p>
                    <div class="code-block text-sm">
                        <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
                        <pre class="text-gray-300"><code>public static ListNode mergeLists(ListNode l1, ListNode l2) {
    ListNode dummy = new ListNode(0);
    ListNode tail = dummy;
    while (l1 != null && l2 != null) {
        if (l1.val &lt; l2.val) {
            tail.next = l1;
            l1 = l1.next;
        } else {
            tail.next = l2;
            l2 = l2.next;
        }
        tail = tail.next;
    }
    tail.next = (l1 != null) ? l1 : l2;
    return dummy.next;
}</code></pre>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Full Implementation -->
    <section class="py-16 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="mb-8 text-center">
                <h2 class="text-3xl font-bold mb-4">完整实现</h2>
                <div class="w-20 h-1 bg-indigo-500 mx-auto"></div>
            </div>
            
            <div class="bg-white rounded-lg shadow-lg overflow-hidden">
                <div class="code-block text-sm">
                    <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
                    <pre class="text-gray-300"><code>public class LinkedListReorderDemo {

    // 链表节点类
    static class ListNode {
        int val;
        ListNode next;

        ListNode(int val) {
            this.val = val;
            this.next = null;
        }
    }

    // 分离奇偶位链表
    public static ListNode[] splitOddEven(ListNode head) {
        ListNode oddHead = new ListNode(0);
        ListNode evenHead = new ListNode(0);
        ListNode odd = oddHead;
        ListNode even = evenHead;
        ListNode current = head;
        boolean isOdd = true;

        while (current != null) {
            if (isOdd) {
                odd.next = current;
                odd = odd.next;
            } else {
                even.next = current;
                even = even.next;
            }
            current = current.next;
            isOdd = !isOdd;
        }

        odd.next = null;
        even.next = null;

        return new ListNode[]{oddHead.next, evenHead.next};
    }

    // 反转链表
    public static ListNode reverseList(ListNode head) {
        ListNode prev = null;
        ListNode curr = head;
        while (curr != null) {
            ListNode next = curr.next;
            curr.next = prev;
            prev = curr;
            curr = next;
        }
        return prev;
    }

    // 排序链表
    public static ListNode sortList(ListNode head) {
        LinkedList&lt;Integer&gt; list = new LinkedList&lt;&gt;();
        ListNode current = head;
        while (current != null) {
            list.add(current.val);
            current = current.next;
        }
        Collections.sort(list);

        ListNode sortedHead = new ListNode(list.get(0));
        ListNode sortedCurrent = sortedHead;
        for (int i = 1; i &lt; list.size(); i++) {
            sortedCurrent.next = new ListNode(list.get(i));
            sortedCurrent = sortedCurrent.next;
        }
        return sortedHead;
    }

    // 合并两个有序链表
    public static ListNode mergeLists(ListNode l1, ListNode l2) {
        ListNode dummy = new ListNode(0);
        ListNode tail = dummy;
        while (l1 != null && l2 != null) {
            if (l1.val &lt; l2.val) {
                tail.next = l1;
                l1 = l1.next;
            } else {
                tail.next = l2;
                l2 = l2.next;
            }
            tail = tail.next;
        }
        tail.next = (l1 != null) ? l1 : l2;
        return dummy.next;
    }

    public static void main(String[] args) {
        // 创建一个链表：1 -> 4 -> 3 -> 2 -> 5
        ListNode head = new ListNode(1);
        head.next = new ListNode(4);
        head.next.next = new ListNode(3);
        head.next.next.next = new ListNode(2);
        head.next.next.next.next = new ListNode(5);

        // 分离奇偶位链表
        ListNode[] separated = splitOddEven(head);
        ListNode oddList = separated[0];
        ListNode evenList = separated[1];

        // 排序奇偶位链表
        oddList = sortList(oddList);
        evenList = reverseList(evenList);
        evenList = sortList(evenList);

        // 合并两个链表
        ListNode sortedList = mergeLists(oddList, evenList);

        // 打印结果
        ListNode current = sortedList;
        while (current != null) {
            System.out.print(current.val + " ");
            current = current.next;
        }
        // 输出: 1 2 3 4 5
    }
}</code></pre>
                </div>
            </div>
        </div>
    </section>

    <!-- Visual Demo -->
    <section class="py-16 px-4 bg-gray-100">
        <div class="container mx-auto max-w-6xl">
            <div class="mb-8 text-center">
                <h2 class="text-3xl font-bold mb-4">可视化演示</h2>
                <div class="w-20 h-1 bg-indigo-500 mx-auto"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 items-center">
                <div>
                    <h3 class="text-xl font-semibold mb-4">原始链表</h3>
                    <div class="flex items-center justify-center bg-white p-6 rounded-lg shadow">
                        <div class="list-node odd">1</div>
                        <div class="list-node even">4</div>
                        <div class="list-node odd">3</div>
                        <div class="list-node even">2</div>
                        <div class="list-node odd">5</div>
                    </div>
                    <p class="text-center mt-4 text-gray-600">奇数位(蓝色): 1 → 3 → 5 (升序)<br>偶数位(紫色): 4 → 2 (降序)</p>
                </div>
                <div>
                    <h3 class="text-xl font-semibold mb-4">处理过程</h3>
                    <div class="mermaid">
                        graph TD
                        A[原始链表 1→4→3→2→5] --> B[分离奇偶位]
                        B --> C[奇数位链表 1→3→5]
                        B --> D[偶数位链表 4→2]
                        D --> E[反转偶数位 2→4]
                        C --> F[合并两个链表]
                        E --> F
                        F --> G[排序后链表 1→2→3→4→5]
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Complexity Analysis -->
    <section class="py-16 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="mb-8 text-center">
                <h2 class="text-3xl font-bold mb-4">复杂度分析</h2>
                <div class="w-20 h-1 bg-indigo-500 mx-auto"></div>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8">
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-xl font-semibold mb-3 flex items-center">
                        <i class="fas fa-clock text-indigo-500 mr-3"></i>时间复杂度
                    </h3>
                    <ul class="text-gray-700 space-y-2">
                        <li>• 分离链表: O(n)</li>
                        <li>• 反转链表: O(n/2) ≈ O(n)</li>
                        <li>• 排序链表: O(n log n) (使用归并排序)</li>
                        <li>• 合并链表: O(n)</li>
                        <li class="font-semibold mt-2">总时间复杂度: O(n log n)</li>
                    </ul>
                </div>
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-xl font-semibold mb-3 flex items-center">
                        <i class="fas fa-memory text-indigo-500 mr-3"></i>空间复杂度
                    </h3>
                    <ul class="text-gray-700 space-y-2">
                        <li>• 分离链表: O(1)</li>
                        <li>• 反转链表: O(1)</li>
                        <li>• 排序链表: O(n) (使用额外空间)</li>
                        <li>• 合并链表: O(1)</li>
                        <li class="font-semibold mt-2">总空间复杂度: O(n)</li>
                    </ul>
                </div>
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-xl font-semibold mb-3 flex items-center">
                        <i class="fas fa-lightbulb text-indigo-500 mr-3"></i>优化建议
                    </h3>
                    <ul class="text-gray-700 space-y-2">
                        <li>• 可以使用原地排序算法减少空间使用</li>
                        <li>• 对于已部分排序的链表可以优化排序过程</li>
                        <li>• 考虑使用递归方式简化代码</li>
                        <li>• 对于大链表可以采用并行处理</li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-8 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold">技术小馆</h3>
                    <p class="text-gray-400 mt-1">专业的算法与数据结构学习平台</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300">
                        <i class="fas fa-globe mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-6 pt-6 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // Copy code function
        function copyCode(button) {
            const codeBlock = button.nextElementSibling;
            const range = document.createRange();
            range.selectNode(codeBlock);
            window.getSelection().removeAllRanges();
            window.getSelection().addRange(range);
            document.execCommand('copy');
            window.getSelection().removeAllRanges();
            
            const originalText = button.innerHTML;
            button.innerHTML = '<i class="fas fa-check"></i> 已复制';
            setTimeout(() => {
                button.innerHTML = originalText;
            }, 2000);
        }

        // Smooth scrolling
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```